package com.code.demo.ui.common;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.code.demo.R;


public class DialogUpdate {

    private Dialog mDialog;
    private TextView dialog_message;
    private View dialog_line;
    public TextView positive;
    public TextView negative;

    public DialogUpdate(Context context, String message) {

        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.widget_dialog_update, null);

        mDialog = new Dialog(context, R.style.dialog);
        mDialog.setContentView(view);
        mDialog.setCanceledOnTouchOutside(false);
        mDialog.setOnKeyListener(new DialogInterface.OnKeyListener() {
            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                    return true;
                }
                return false;
            }
        });
        dialog_message = (TextView) view.findViewById(R.id.dialog_message);
        dialog_message.setText(message);

        positive = (TextView) view.findViewById(R.id.confirm);
        negative = (TextView) view.findViewById(R.id.cancel);
    }

    public void show() {
        mDialog.show();
    }

    public void dismiss() {
        mDialog.dismiss();
    }

}
